
def get_breadcrumb(cat):
    # cat 不知道是几级分类
    breadcrumb = {
        'cat1': '',
        'cat2': '',
        'cat3': ''
    }

    if cat.parent is None:
        # 分类没有父分类,肯定是一级分类
        breadcrumb['cat1'] = cat
    elif cat.subs.count() == 0:
        # 没有子类了,就是三级
        breadcrumb['cat3'] = cat

        breadcrumb['cat2'] = cat.parent

        breadcrumb['cat1'] = cat.parent.parent
    else:
        breadcrumb['cat2'] = cat
        breadcrumb['cat1'] = cat.parent

    return breadcrumb
